//
//  GWMineViewController.m
//  ShandsMod
//
//  Created by zh_s on 2019/9/27.
//  Copyright © 2019 zh_s. All rights reserved.
//

#import "GWMineViewController.h"
#import "MineListCell.h"
#import "MineTotalPriceVC.h"
#import "AboutVC.h"

@interface GWMineViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *mainTableView;
@property (nonatomic, strong) NSArray *dataArr;
@property (nonatomic, strong) NSArray *dataIMGArr;

@end

@implementation GWMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navTitle = @"我的";
    self.leftTitle = @"";
    self.isShadow = YES;
    self.view.backgroundColor = UIColor.whiteColor;
    [self data_init];
    [self UI_init];
    // Do any additional setup after loading the view.
}

#pragma mark ----- UI_init
- (void)UI_init {
    [self.view addSubview:self.mainTableView];
}
#pragma mark ----- data_init
- (void)data_init {
    _dataArr = @[@"资产总览",@"交易记录",@"我的NFT",@"关于我们"];
    _dataIMGArr = @[@"icon_mine_price",@"icon_mine_record",@"icon_mine_NFT",@"icon_mine_about"];
}
#pragma mark ----- tableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MineListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.titleLab.text = _dataArr[indexPath.row];
    cell.iconImg.image = IMAGE_NAME(_dataIMGArr[indexPath.row]);
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        MineTotalPriceVC *vc =  [[MineTotalPriceVC alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 3) {
        AboutVC *vc = [[AboutVC alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
}


#pragma mark ----- 懒加载
- (UITableView *)mainTableView {
    if (!_mainTableView) {
        _mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT + 4, SCREEN_WIDTH, SCREEN_HEIGHT -NAV_HEIGHT - 100) style:UITableViewStyleGrouped];
        _mainTableView.delegate = self;
        _mainTableView.dataSource = self;
        _mainTableView.showsVerticalScrollIndicator = NO;
        _mainTableView.rowHeight = 54;
        _mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
        _mainTableView.backgroundColor = [UIColor whiteColor];
        [_mainTableView registerClass:[MineListCell class] forCellReuseIdentifier:@"cell"];
    }
    return _mainTableView;
}

@end
